#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main()
{
    int n = 0;
    cin >> n;
    cerr << "n=" << n << endl;
    string s;
    cin >> s;
    //cerr<<s<<endl;
    vector<bool> dp(n);
    int r1 = 0, r0 = 0, w1 = 0, w0 = 0;
    for (int i = 0;i < n;i++)
    {
        if (i < n / 2)
        {
            if (s[i] == '1') ++r1;
            else if (s[i] == '0') ++r0;
        }
        else
        {
            if (s[i] == '1') ++w1;
            else if (s[i] == '0') ++w0;
        }
    }
    int count = 0;
    if (r1 == w1 && r0 == w0) count++;//dp[n/2-1]=true;
    int l = 1, r = n / 2;
    while (l < n)
    {
        //cerr<<"l="<<l<<",r="<<r<<endl;
        if (s[l - 1] == '1')
        {
            --r1;
            ++w1;
        }
        else if (s[l - 1] == '0')
        {
            --r0;
            ++w0;
        }
        if (s[r] == '1')
        {
            ++r1;
            --w1;
        }
        else if (s[r] == '0')
        {
            ++r0;
            --w0;
        }
        if (r1 == w1 && r0 == w0) count++;
        l++;
        r++;
        r %= n;
        //cerr<<"count="<<count<<endl;
    }
    cerr << count << endl;
    cout << count << endl;
}
